package org.example.server.read;

import com.alibaba.fastjson.JSONObject;
import lombok.Setter;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;

@Setter
public abstract class ReadStrategy {
    protected JSONObject dataJsonObject;
    protected Socket socket;

    public abstract void operateData();

    public void setSocket(Socket socket) {
        this.socket = socket;
    }

    public void sendMessage(String message) {
        try {
            PrintWriter pw = new PrintWriter(socket.getOutputStream());
            pw.write(message);
            pw.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
